package school30;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;

class MainCanvas extends Canvas
        implements Runnable
{
  int[] buffer = null;
  Display display; // the display for the application

  public MainCanvas(Display d,int[] rgbData) {
    display = d;
    buffer = rgbData;
  }

// paint the current frame
  public void paint( Graphics g )
  {
    g.drawRGB(buffer,
            0,  // offset
            getWidth(), //scan
            0,
            0,
            getWidth(),
            getHeight(),
            true);
  }

  public void startAnimation()
  {
// set up initial frame
    repaint();
    display.callSerially(this);
  }
// called after previous repaint is finished
  public void run()
  {
    if (true)
    {
// set up the next frame
      repaint();
      display.callSerially(this);
    }
  }
}
